//package com.sunop.pantigateway.config;
//
//import feign.RequestInterceptor;
//import feign.RequestTemplate;
//import jakarta.servlet.http.HttpServletRequest;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//@Component
//public class FeignTokenInterceptor implements RequestInterceptor {
//    @Override
//    public void apply(RequestTemplate template) {
//        // 1. 从当前请求上下文中获取HttpServletRequest
//        ServletRequestAttributes attributes = (ServletRequestAttributes)
//            RequestContextHolder.getRequestAttributes();
//        if (attributes != null) {
//            HttpServletRequest request = attributes.getRequest();
//
//            // 2. 获取Token（需与Sa-Token配置的token-name一致，默认是satoken）
//            String token = request.getHeader("token");
//            if (token != null && !token.isEmpty()) {
//                // 3. 将Token添加到Feign请求头
//                template.header("token", token);
//            }
//        }
//    }
//}